package mycine.model.beans;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;

/**
 *
 * @author Vincent
 */
@Entity
@Table(name = "series")
@NamedQueries({
	@NamedQuery(name = "Series.findAll", query = "SELECT s FROM Series s"),
	@NamedQuery(name = "Series.findById", query = "SELECT s FROM Series s WHERE s.id = :id"),
	@NamedQuery(name = "Series.findByTitle", query = "SELECT s FROM Series s WHERE s.title = :title"),
	@NamedQuery(name = "Series.findBySeason", query = "SELECT s FROM Series s WHERE s.season = :season")})
public class Series implements Serializable {
	private static final long serialVersionUID = 1L;
	@Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
	private Integer id;
	@Basic(optional = false)
    @Column(name = "title")
	private String title;
	@Basic(optional = false)
    @Column(name = "season")
	private int season;
	@Lob
    @Column(name = "description")
	private String description;
	@ManyToMany(mappedBy = "seriesList")
	private List<Usermc> usermcList;
	@OneToMany(cascade = CascadeType.ALL, mappedBy = "series")
	private List<Episode> episodeList;

	public Series() {
	}

	public Series(Integer id) {
		this.id = id;
	}

	public Series(Integer id, String title, int season) {
		this.id = id;
		this.title = title;
		this.season = season;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public int getSeason() {
		return season;
	}

	public void setSeason(int season) {
		this.season = season;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public List<Usermc> getUsermcList() {
		return usermcList;
	}

	public void setUsermcList(List<Usermc> usermcList) {
		this.usermcList = usermcList;
	}

	public List<Episode> getEpisodeList() {
		return episodeList;
	}

	public void setEpisodeList(List<Episode> episodeList) {
		this.episodeList = episodeList;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are not set
		if (!(object instanceof Series)) {
			return false;
		}
		Series other = (Series) object;
		if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "mycine.model.beans.Series[ id=" + id + " ]";
	}
	
}
